<template>
	<el-dialog :visible.sync="addBottleShow"  @close="$emit('update:showAddBottle',false)" width="45%"  :show-close='false' :append-to-body='true'>
		<span slot="title" class="dialog-title">
		  	{{title}}
			<el-button  size="mini" class="popupClose" @click="resetAddBottleForm">关闭</el-button>
			  </span>
		<el-form label-width="110px" :inline="false" class="demo-form-inline" :model="wereData" :rules="addBottleRules" ref="sampleForm">
			<el-form-item label="仓库名称">
				<el-col :span="22">
					<el-input v-model="wereData.name" size = "mini"> </el-input>
				</el-col>
			</el-form-item>
		</el-form>
		<span slot="footer" class="dialog-footer">
			    <el-button type="primary" @click="submit"  size = "mini">提 交</el-button>
			    <el-button  size="mini" @click="resetAddBottleForm">取 消</el-button>
			  </span>
	</el-dialog>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		props: ['showAddBottle', 'wereData', 'title'],
		data() {
			return {
				addBottleRules: {}
			}
		},
		computed: {
			...mapState(['submitType']),
			addBottleShow: {
				get: function () {

					return this.showAddBottle
				},
				set: function (newValue) {

				}
			}
		},
		mounted() {

		},
		methods: {
			resetAddBottleForm() {
				this.$emit('update:showAddBottle', false)
			},
			submit() {
				let url;
				if (this.title == '添加仓库') {
					url = '/system/addStock.htm'
					this.wereData.submitType = this.submitType.submitOpen
				} else if (this.title == '编辑仓库') {
					url = '/system/updateStock.htm'
					this.wereData.submitType = this.submitType.submitOpen
				}
				this.$http({
					method: 'post',
					apiUrl: url,
					params: this.wereData,
					isJson: true,
				}).then(res => {
					if (res.code === 0) {
						this.$message({
							showClose: true,
							message: '操作成功！',
							type: 'success'
						})
						this.resetAddBottleForm()
						this.$parent.readStockList()
					}
				}, )
			}

		}
	}

</script>

<style>

</style>